﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

public partial class order1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //string teliphone = Session["teliphone"].ToString() ;
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridView1.DataSourceID = OrderDS.ID;
    }
    private double sum = 0;

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex >= 0)
        {
            sum += Convert.ToDouble(e.Row.Cells[7].Text);
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[6].Text = "总计：";
            e.Row.Cells[7].Text = sum.ToString();
            //e.Row.Cells[2].Text = "平均价格：";  
            //e.Row.Cells[3].Text = ((int)(sum / GridView1.Rows.Count)).ToString(); 
        }
    }
        public void bind()
    {
        SqlConnection cn = new SqlConnection();
        cn.ConnectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=HotelManagement;Integrated Security=True";
        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter myds = new SqlDataAdapter(cmd);
        cn.Open();
        GridView1.DataSource = myds;
        GridView1.DataKeyNames = new string[] { };
        GridView1.DataBind();
        cn.Close();

    }
        protected void  GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1 .EditIndex =e .NewEditIndex;
    }
}
